package com.itheima.file;

import java.io.File;

public class Test02 {
    public static void main(String[] args) {
        File file = new File("D:\\aaa");
        deleteFile(file);
    }

    private static void deleteFile(File file) {
        //判断File是否为空
        if (file != null) {
            File[] files = file.listFiles();
            //判断数组是是否为空
            if (files != null) {
                //遍历数组
                for (File f : files) {
                    //判断是否为文件夹
                    if (f.isDirectory()) {
                        //递归调用
                        deleteFile(f);
                    } else {
                        f.delete();
                    }
                }
                file.delete();
            }
        }
    }
}

